{% extends 'base/base.html' %}
{% block title %}浏览历史记录{% endblock %}
<h1>1111111111</h1>
{% block main %}
<div class="container mt-4">
    <div class="row">
        <div class="col-md-8 col-md-offset-2">
            <h2>浏览历史记录</h2>
            

            <div class="panel panel-default">
                {% if test_data %}
                    <table class="table table-hover table-responsive">
                        <thead>
                            <tr>
                                <th>文章标题</th>
                                <th>作者</th>
                                <th>浏览时间</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            {% for item in test_data %}
                            <tr>
                                <td>{{ item.article_title }}</td>
                                <td>{{ item.article_author }}</td>
                                <td>{{ item.browse_time|date:"Y-m-d H:i:s" }}</td>
                                <td>
                                    <a href="{% url 'main:article_detail' item.article_id %}" class="btn btn-sm btn-primary">再次查看</a>
                                    <a href="{% url 'main:delete_history' item.id %}" class="btn btn-sm btn-danger" onclick="return confirm('确定要删除这条浏览记录吗？');">删除</a>
                                </td>
                            </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                {% else %}
                    <div class="panel-body text-center">
                        <p class="text-muted">暂无浏览历史记录</p>
                        {% if user.is_authenticated %}
                            <a href="{% url 'main:index' %}" class="btn btn-primary">浏览文章</a>
                        {% else %}
                            <a href="{% url 'user:login' %}" class="btn btn-primary">登录查看历史</a>
                        {% endif %}
                    </div>
                {% endif %}
            </div>
        </div>
    </div>
</div>
{% endblock %}